package fileparsing;

import guiobjects.Observation;

import java.io.File;
import java.util.Scanner;
import java.util.ArrayList;

import user.data.Data;



/**
 * Reads in a file and produces a List of Observations from it.
 * 
 * @author Trevor Terris
 *
 */

public class ReadObservations 
{
	
	public static ArrayList<Observation> listOfObservations(String dirName)
	{
		ArrayList<Observation> listOfObservations = new ArrayList<Observation>();
		try
		{
            File f = new File(dirName + "/" + Data.RAW_DATA_NAME);

			Scanner s = new Scanner(f);
			if (s.hasNextInt())
				s.nextInt();
			while(s.hasNext())
			{
				s.next();
				Observation thisObservation = new Observation();
				thisObservation.frameNum = s.nextInt();
				thisObservation.parseText(s.nextLine());
				listOfObservations.add(thisObservation);
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("File not found!");
		}
		return listOfObservations;
	}
}
